package net_1011;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86187
 * Date: 2022-10-14
 * Time: 10:41
 */
public class UdpTranslateServer extends UdpEchoServer{
    private HashMap<String,String> dictionary = new HashMap<>();
    public UdpTranslateServer(int port) throws SocketException {
        super(port);
        dictionary.put("cat","猫");
        dictionary.put("dog","狗");
        dictionary.put("fuck","卧槽");
        dictionary.put("love","爱");
    }

    @Override
    public String process(String request) {
        return dictionary.getOrDefault(request,"未查询到相关词汇");
    }

    public static void main(String[] args) throws IOException {
        UdpTranslateServer server = new UdpTranslateServer(9090);
        server.start();
    }
}
